﻿using Sunboxsoft.ChanceData.ServiceProxy.DataServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Script
{
    public class DataSeriesScriptObject
    {
        public DataSeriesScriptObject(DataSeries dataSeries)
        {
            this.id = dataSeries.Id;
            this.name = dataSeries.Name;

            if (dataSeries.DataItems != null)
            {
                this.items = new DataItemScriptObject[dataSeries.DataItems.Length];
                for (int index = 0; index < items.Length; index++)
                {
                    this.items[index] = new DataItemScriptObject(dataSeries.DataItems[index]);
                }
            }
        }

        public string id
        {
            get;
            private set;
        }

        public string name
        {
            get;
            private set;
        }

        public DataItemScriptObject[] items
        {
            get;
            private set;
        }

        public DataItemScriptObject getItem(string itemId)
        {
            for (int index = 0; index < items.Length; index++)
            {
                if (items[index].id == itemId)
                {
                    return items[index];
                }
            }
            return null;
        }
    }
}
